<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地图导航</title>
    <style>
        * {
          margin: 0;
          padding: 0;
        }
        #container {
          width: 100%;
          height: 100vh;
          background-color: pink;
        }
    </style>
</head>
<body>
<div id="container"></div>
</body>
</html>


<script type="text/javascript">
  window._AMapSecurityConfig = {
    securityJsCode: "a4367a3e7f3fc8c3b6d4019d8c915911",
  };
</script>
<script
        type="text/javascript"
        src="https://webapi.amap.com/maps?v=2.0&key=1de8e5586855c0c8067b54cab4542e3e"
></script>
<script type="text/javascript">
    //地图初始化应该在地图容器 <div> 已经添加到 DOM 树之后
    var map = new AMap.Map("container", {
      zoom: 12,
    });

    window.onload=function(){
    window.swift.setCurrentLocation()
    }

    function setLocation(lon,lat){
    map.setZoomAndCenter(18,[lon,lat])

const content = `<div class="custom-content-marker"><img src="https:////a.amap.com/jsapi_demos/static/demo-center/icons/dir-via-marker.png"></div>`;
const marker = new AMap.Marker({
  content: content, //自定义点标记覆盖物内容
  position: [lon, lat], //基点位置
  offset: new AMap.Pixel(-13, -30), //相对于基点的偏移位置
});
map.add(marker);

map.plugin(['AMap.PlaceSearch'], function() {
    var PlaceSearchOptions = { //设置PlaceSearch属性
        pageSize: 4, //每页结果数,默认10
        pageIndex: 1, //请求页码，默认1
        map:map,
        extensions: "base" //返回信息详略，默认为base（基本信息）
    };
    var MSearch = new AMap.PlaceSearch(PlaceSearchOptions); //构造PlaceSearch类
    AMap.Event.addListener(MSearch, "complete", (result)=>{window.swift.receiveData(JSON.stringify(result?.poiList?.pois||[]))}); //返回结果
    MSearch.searchNearBy('街道',new AMap.LngLat(lon,lat)); //关键字查询
});

    }
</script>